import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)


const store = new Vuex.Store({
	state: {
		isLogin: false,
		userInfo: {
			name: "",
			role: 0,
			password: "",
			account: 0,
			sex: "",
			area: "",
			identity_card: "",
			depart: "",
			SocketState: {},
			SocketStateErr: {},
		},
		isWacth: false,
		ticketInfo: {
			t_id: "",
			data: [

			]
		}
	},
	mutations: {
		setSocketState(that, info) {
			that.SocketState = info
		},
		setSocketStateErr(that, info) {
			that.SocketStateErr = info;
		},
		login(state, user) {
			state.userInfo = user;
			state.isLogin = true;
			uni.setStorageSync('userInfo', user);
			console.log('已登录');
			console.log('userInfo:' + user);
			console.log('state.userInfo.role :' + state.userInfo.role);
		},
		logout(state) {
			state.isLogin = false;
			state.userInfo = {};
			uni.clearStorageSync('userInfo');
		}
	}
})

export default store
